package com.tuweiya.study.springboot002.controller;

import com.tuweiya.study.springboot002.bean.PersonBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 读取配置文件的person对象
 *      在此类上而外添加@EnableConfigurationProperties注解
 */
@RestController
@RequestMapping(value = "/person")
@EnableConfigurationProperties({PersonBean.class})
public class PersonController {
    @Autowired
    PersonBean personBean;

    /**
     * 读取配置文件赋值的bean对象
     * @return
     */
    @RequestMapping(value = "/readProperties")
    public String readPersonProperties(){
        return personBean.toString();
    }

    @RequestMapping(value = "/read")
    public PersonBean read(){
        return personBean;
    }
}
